var ClubBlendWanfaSettingWindow_Type_Blend = 1;        //混合玩法设置i
var ClubBlendWanfaSettingWindow_Type_TableSetting = 2;//牌桌快速加入设置
var ClubBlendWanfaSettingWindow = Window.extend({
    _ccsFileName: res.ClubBlendWanfaSettingWindow_json,
    _clubId: null,
    _type: null,
    initWindow: function (clubId, type) {
        this._clubId = clubId;
        this._type = type;
        var clubInfo = ClubDataManager.getClubData(clubId);

        this._nodeList['tableSettingTIps'].setVisible(false);
        this._nodeList['lb_content'].setVisible(false);

        if (this._type == ClubBlendWanfaSettingWindow_Type_Blend) {
            if (clubInfo.param && clubInfo.param.free_play) {
                var free_play = clubInfo.param.free_play;
                this._nodeList['btn_open'].setVisible(free_play == 'open' ? true : false);
                this._nodeList['btn_close'].setVisible(free_play == 'close' ? true : false);
            }
            this._nodeList['lb_content'].setVisible(true);
        } else {
            if (clubInfo.param && clubInfo.param.uniqueRoom) {
                var uniqueRoom = clubInfo.param.uniqueRoom;
                this._nodeList['btn_open'].setVisible(uniqueRoom == 'open' ? true : false);
                this._nodeList['btn_close'].setVisible(uniqueRoom == 'close' ? true : false);
            }
            this._nodeList['tableSettingTIps'].setVisible(true);
        }


    },

    _initClickListeners: function () {
        this._clickListeners = {
            'btn_help': '_clickHelp',
            'btn_sure': '_clickOk',
            'btn_open': '_clickOpen',
            'btn_close': '_clickClose',
        };
    },

    _clickHelp: function () {
        showWindow('ClubHelpWindow',ClubHelpWindow_Type.BlendWanfa);
        // this.addChild(new ClubHelpLayer(3), 10);
    },

    _clickOk: function () {
        this.close();
    },

    _clickOpen: function () {
        var clubInfo = ClubDataManager.getClubData(this._clubId);
        if (clubInfo['owner_uid'] != gameData.uid) {
            showAlert('您不是群主，无法操作');
            return;
        }
        this._nodeList['btn_open'].setVisible(false);
        this._nodeList['btn_close'].setVisible(true);
        if (this._type == ClubBlendWanfaSettingWindow_Type_Blend) {
            network.send(2103, {
                cmd: ClubMsgCode.ClubParamSet,
                key: 'free_play',
                value: 'close',
                club_id: this._clubId
            });
        } else if (this._type == ClubBlendWanfaSettingWindow_Type_TableSetting) {
            network.send(2103, {
                cmd: ClubMsgCode.ClubParamSet,
                key: 'uniqueRoom',
                value: 'close',
                club_id: this._clubId
            });
        }

    },

    _clickClose: function () {
        var clubInfo = ClubDataManager.getClubData(this._clubId);
        if (clubInfo['owner_uid'] != gameData.uid) {
            showAlert('您不是群主，无法操作');
            return;
        }
        this._nodeList['btn_open'].setVisible(true);
        this._nodeList['btn_close'].setVisible(false);

        if (this._type == ClubBlendWanfaSettingWindow_Type_Blend) {
            network.send(2103, {cmd: ClubMsgCode.ClubParamSet, key: 'free_play', value: 'open', club_id: this._clubId});
        } else if (this._type == ClubBlendWanfaSettingWindow_Type_TableSetting) {
            network.send(2103, {
                cmd: ClubMsgCode.ClubParamSet,
                key: 'uniqueRoom',
                value: 'open',
                club_id: this._clubId
            });
        }
    },


});